<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>box</div>
    <script>
        var box = document.querySelector('div')
        //箭头函数没有自己this，只能一层忘外找
        box.onclick = () =>{
            console.log(this)
        }

        var a = 20
        var obj = {
            name : 'he',
            
            like : function () {
                // setTimeout(function(){
                //     console.log(this.a)
                // },1000)
                setTimeout (() =>{
                    console.log(this.name)  //this 指的就是，obj.like(),所以this找到的当前对象为obj
                },1000)
            }
        }

        obj.like()
    </script>
</body>
</html>